package demo.wrapper;


public  class FatRmaResultScope{
        /**
         * 最轻量数据返回
         */
        public static final FatRmaResultScope LITE = new FatRmaResultScope(0);
        /**
         * 包含历史记录信息 1
         */
        public static final FatRmaResultScope RMA_HISTORY = new FatRmaResultScope(1);
        /**
         * 商品信息 2
         */
        public static final FatRmaResultScope PRODUCT_INFO = new FatRmaResultScope(2);
        /**
         * 包含商品信息 4+2
         */
        public static final FatRmaResultScope ORDER_ITEM_INFO = new FatRmaResultScope(6);
        /**
         * 订单发货物流信息 8+4+2
         */
        public static final FatRmaResultScope ORDER_LOGISTICS_INFO = new FatRmaResultScope(14);
        /**
         * RMA物流信息 16
         */
        public static final FatRmaResultScope RMA_LOGISTICS_INFO = new FatRmaResultScope(16);
        /**
         * 供应商信息 64
         */
        public static final FatRmaResultScope SUPPLIER_INFO = new FatRmaResultScope(32);
        /**
         * 用户信息 128
         */
        public static final FatRmaResultScope USER_INFO = new FatRmaResultScope(64);

        /**
         * 订单备注信息
         */
        public static final FatRmaResultScope ORDER_ITEM_NOTE = new FatRmaResultScope(128);

        public int scope;

        private FatRmaResultScope() {
            scope = LITE.scope;
        }

        private FatRmaResultScope(int scope) {
            this.scope = scope;
        }

        public static class FatRmaResultScopeBuilder {
            int scope = LITE.scope;

            /**
             * 扩充scope范围
             *
             * @param extendedScope
             * @return
             */
            public FatRmaResultScopeBuilder extend(FatRmaResultScope extendedScope) {
                this.scope = extendedScope.scope | this.scope;
                return this;
            }

            public FatRmaResultScope build() {
                return new FatRmaResultScope(this.scope);
            }
        }

        /**
         * 是否当前scope被source包含
         *
         * @param source
         * @return
         */
        public boolean isExtended(FatRmaResultScope source) {
            if (source == null) {
                return false;
            }
            return (this.scope & source.scope) == this.scope;
        }
    }